#include <iostream>
#include <fstream>
#include <cstdio>

#include "set_test_file.h"

void CreateTestFile(){
	std::ofstream testfile("config_test.ini", std::ios::trunc);
	if (!testfile.is_open()){
		std::cout << "Error opening test file!" << std::endl;
		return;
	}
	testfile << ";This is a test file" << std::endl;
	testfile << "[string]" << std::endl;
	//normal
	testfile << "string-1=\"hello-world\"" << std::endl;
	//with spaces
	testfile << " string-2 = \"hello-world\" " << std::endl;
	//with tabs
	testfile << "	string-3	=	\"hello-world\"	" << std::endl;
	//with comments using ';'
	testfile << "string-4=\"hello-world\" ;set string-3" << std::endl;
	//with comments using '#'
	testfile << "string-5=\"hello-world\" #set string-4" << std::endl;
	//with comments using '//'
	testfile << "string-6=\"hello-world\" //set string-5" << std::endl;
	//support without ""
	testfile << "string-7=hello-world" << std::endl;
	//null
	testfile << "string-8=" << std::endl;


	testfile << "[number]" << std::endl;
	testfile << "zero=0" << std::endl;
	testfile << "int-positive=3" << std::endl;
	testfile << "int-negative=-3" << std::endl;
	testfile << "float-positive=3.14" << std::endl;
	testfile << "float-negative=-3.14" << std::endl;
	testfile << "double-positive=0.123456789" << std::endl;
	testfile << "double-negative=-0.123456789" << std::endl;
	testfile << "number-error-null=" << std::endl;
	testfile << "number-error-string=\"string\"" << std::endl;
	testfile << "number-error=string" << std::endl;

	testfile << "[bool]" << std::endl;
	testfile << "bool-true=true" << std::endl;
	testfile << "bool-false=false" << std::endl;
	testfile << "bool-error-null=" << std::endl;
	testfile << "bool-error-number=1" << std::endl;
	testfile << "bool-error-string=string" << std::endl;
	testfile.close();
}

void DeleteTestFile(){
	if (remove("config_test.ini")){
		std::cerr << "Error deleting test file!" << std::endl;
		return;
	}
}